package com.tyk.bookstore.back.platform.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tyk.bookstore.back.common.core.util.FileUtil;
import com.tyk.bookstore.back.platform.model.enume.CarouselState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;


@Schema(name = "Carousel", description = "轮播图")
@TableName("carousel")
@Data
public class CarouselDo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1;

    public static final Long TOP_ID = 0L;

    @Schema(description = "ID")
    @TableId("id")
    private Long id;

    @Schema(description = "路径")
    @TableField("path")
    private String path;

    @Schema(description = "关联链接")
    @TableField("link")
    private String link;

    @Schema(description = "优先级")
    @TableField("priority")
    private Integer priority;

    @Schema(description = "状态[0不可用,1可用]")
    @TableField("state")
    private CarouselState state;

    @Schema(description = "描述")
    @TableField("description")
    private String description;

    @Schema(description = "创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;

    public CarouselDo setPath(String path) {
        this.path = FileUtil.relativePath(path);
        return this;
    }
}
